<div class="main-content" id="main-content">
	<div class="sub-content">
		<div class="top-header">
			<h1>User Profile</h1>
		</div>
		
		<div class="top-links btn-active">
			<ul>
				<?php if(isset($_GET['user']) && $_GET['user']!=''){  ?>
						<li class="active-menu"><a href="/admin/add-user-previous?user=<?php echo $_GET['user'];?>"><span>1</span></a></li>
						<li><a  href="/admin/add-user-next?user=<?php echo $_GET['user']; ?>"><span>2</span></a></li>
					<?php }else{ ?>
				<li class="active-menu"><a href="/admin/add-user-previous"><span>1</span></a></li>
				<li><a  href="/admin/add-user-next"><span>2</span></a></li>
				<?php } ?>
				<li><span>3</span></li>
			</ul>
		</div>
		<div class="middle-forms user-profile1">
			<form id="formid" method="post" >
				<div class="sub-forms">
					<div class="forms-list">
						<label>Contact Person 1</label>
						<input  type="text" id="cperson" name="cperson" value="<?php if(isset($_SESSION['adminusers']['cperson'])){ echo $_SESSION['adminusers']['cperson'];} ?>" placeholder="Contact Person 1"> 
					</div><span style="color:red" id="errorcperson"></span>
					<div class="forms-list">
						<label>Mobile No</label>
						<input  type="text" id="mobile" name="mobile" value="<?php if(isset($_SESSION['adminusers']['mobile'])){ echo $_SESSION['adminusers']['mobile'];} ?>" placeholder="mobile No" />
					</div><span style="color:red" id="errormobile"></span>
					<div class="forms-list">
						<label>Email Address</label>
						<input  type="text" id="email" name="email" value="<?php if(isset($_SESSION['adminusers']['second_email'])){ echo $_SESSION['adminusers']['second_email'];} ?>" placeholder="Email" />
					</div></span><span style="color:red" id="erroremail"></span>
				    <div class="forms-list">
						<label>Bank Address</label>
						<textarea  id="baddress" name="baddress" placeholder="Bank Address" ><?php if(isset($_SESSION['adminusers']['baddress'])){ echo $_SESSION['adminusers']['baddress'];} ?></textarea>
					</div><span style="color:red" id="errorbaddress"></span>
					<div class="forms-list">
						<label>Account No</label>
						<input  type="text" id="acno" name="acno" value="<?php if(isset($_SESSION['adminusers']['acno'])){ echo $_SESSION['adminusers']['acno'];} ?>" placeholder="Account No" />
					</div><span style="color:red" id="erroracno"></span>
					<div class="forms-list">
						<label>Note</label>
						<textarea  id="note" name="note" placeholder="Note" ><?php if(isset($_SESSION['adminusers']['note'])){ echo $_SESSION['adminusers']['note'];} ?></textarea>
					</div><span style="color:red" id="errornote"></span>
					<div class="forms-list">
						<label>User Type</label>
						<div class="select_6">
							<select id="type" name="type">
								<? if(isset($_SESSION['admin']['user_type']) && $_SESSION['admin']['user_type']=="admin"){?>
									<option value="user" <?php if(isset($_SESSION['adminusers']['type'])){ if($_SESSION['adminusers']['type']=='user'){ echo 'selected="selected"'; }} ?> >User</option>								
								<?}else if(isset($_SESSION['admin']['user_type']) && $_SESSION['admin']['user_type']=="superadmin"){?>
									<option value="0">Select</option>
									<option value="user" <?php if(isset($_SESSION['adminusers']['type'])){ if($_SESSION['adminusers']['type']=='user'){ echo 'selected="selected"'; }} ?> >User</option>								
									<option value="admin" <?php if(isset($_SESSION['adminusers']['type'])){ if($_SESSION['adminusers']['type']=='admin'){ echo 'selected="selected"'; }} ?> >Admin</option>
								<?}?>								
							</select>
						</div>
					</div><span style="color:red" id="errornote"></span>
					<?php if(isset($_GET['user']) && $_GET['user']!=''){  ?>
							<input type="hidden" id="user" name="user" value="<?php echo $_GET['user']; ?>">
					<div class="forms-list">
						<label>Status</label>
						<div class="select_6">
							<select id="u_status" name="u_status">
							<option value="0" <?php if(isset($_SESSION['adminusers']['u_status'])){ if($_SESSION['adminusers']['u_status']=='0'){ echo 'selected="selected"'; }} ?> >Pending</option>
							<option value="1" <?php if(isset($_SESSION['adminusers']['u_status'])){ if($_SESSION['adminusers']['u_status']=='1'){ echo 'selected="selected"'; }} ?> >Active</option>
							<option value="2" <?php if(isset($_SESSION['adminusers']['u_status'])){ if($_SESSION['adminusers']['u_status']=='2'){ echo 'selected="selected"'; }} ?> >In Active</option>
							</select>
						</div>
					</div>
					<div class="forms-list">
						<button  id="register" onclick="return registrationsucc();">Update</button>
					</div>
					<?php }else{ ?>
					<div class="forms-list">
						<button  id="register" onclick="return registrationsucc();">Register</button>
					</div>
					<?php } ?>
				</div>
			</form>
		</div>
	</div>
</div>
<script type="text/javascript">
function registrationsucc(){
        var flag=true;	
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var letters = /^[a-zA-Z ]*$/; 
		var numbers = /^[0-9]+$/;
		var cperson=$('#cperson').val();
		var mnumber=$('#mobile').val();
		var email=$('#email').val();  
		var cperson1=$('#cperson1').val();
		var mnumber1=$('#mobile1').val();
		var email1=$('#email1').val(); 
		var bankaddress=$('#baddress').val();
		var acnumber=$('#acno').val();
		var note=$('#note').val(); 
		
		if(cperson==""){
			$('#errorcperson').html('*Please enter contact person');	
			flag=false;
		}else if(!cperson.match(letters)){
			$('#errorcperson').html('');
			$("#errorcperson").html("*Please enter characters only");
			flag=false;
		}else{
			$('#errorcperson').html('');
		}
		if(mnumber==""){
		  $('#errormobile').html('*Please enter mobile number');
		  flag=false;
		}else if(!mnumber.match(numbers)){
			$('#errormobile').html('Please enter numbers only');
			flag=false;
		}else if(mnumber.length<10 || mnumber.length>10 ){
			$('#errormobile').html('Invalid phonenumber');
			flag=false;
		}else{
			$('#errormobile').html('');
		}
		if(email==""){
		  $('#erroremail').html('*Please enter email');
		}else if(!filter.test(email)){
		  $('#erroremail').html('Email format is not correct');
		}else{
		   $('#erroremail').html('');
		}
		if(bankaddress==""){
			$('#errorbaddress').html('*Please enter bankaddress');	
			flag=false;
		}else{
			$('#errorbaddress').html('');
		}
		if(acnumber==""){
			$('#erroracno').html('*Please enter account number');	
			flag=false;
		}else{
			$('#erroracno').html('');
		}
		if(note==""){
			$('#errornote').html('*Please enter note');	
			flag=false;
		}else{
			$('#errornote').html('');
		}
		if(flag==false){ 
			return false;
		}else{		
			$("#formid").submit();
		}
}
</script>
       
